﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoreRay
{
    public struct Color : IEquatable<Color>
    {
        public Color(float red, float green, float blue) : this(red, green, blue, 1.0f)
        {
        }

        public Color(float red, float green, float blue, float alpha) : this()
        {
            this.Red = red;
            this.Green = green;
            this.Blue = blue;
            this.Alpha = alpha;
        }

        public float Red
        {
            get;
            private set;
        }

        public float Green
        {
            get;
            private set;
        }

        public float Blue
        {
            get;
            private set;
        }

        public float Alpha
        {
            get;
            set;
        }

        public static bool operator ==(Color color1, Color color2)
        {
            return color1.Equals(color2);
        }

        public static bool operator !=(Color color1, Color color2)
        {
            return !color1.Equals(color2);
        }

        public override bool Equals(object obj)
        {
            return obj is Color ? Equals((Color) obj) : false;
        }

        public override int GetHashCode()
        {
            return this.Red.GetHashCode() ^ this.Green.GetHashCode() ^ this.Blue.GetHashCode() ^ this.Alpha.GetHashCode();
        }

        public bool Equals(Color other)
        {
            return this.Red == other.Red && this.Green == other.Green && this.Blue == other.Blue && this.Alpha == other.Alpha;
        }
    }
}
